package com.jwthhealth_pub.app;

import android.content.Context;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.support.multidex.MultiDex;
import android.support.multidex.MultiDexApplication;

import com.jwthhealth_pub.common.preference.PreferenceUtil;
import com.jwthhealth_pub.old.api.ApiHelper;
import com.jwthhealth_pub.old.common.Constant;

/**
 * main app
 * Created by liuzhen on 2017/12/4.
 */

public class App extends MultiDexApplication {

    public static Context mContext;

    public static PreferenceUtil preferenceUtil;
    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }

    @Override
    public void onCreate() {
        super.onCreate();

        mContext = getApplicationContext();

        preferenceUtil = PreferenceUtil.getInstance();

        //获取wifi地址
        String mac = "";
        // 获取wifi管理器
        WifiManager wifiMng = (WifiManager) getSystemService(Context.WIFI_SERVICE);
        WifiInfo wifiInfor = wifiMng.getConnectionInfo();
        mac = wifiInfor.getMacAddress();
        if (mac != null) {
            String replaceMac = mac.replace(":", "-");
            String lowerCaseMac = replaceMac.toLowerCase();
            preferenceUtil.putString(Constant.MAC_ADDRESS, lowerCaseMac);
        } else {
            preferenceUtil.putString(Constant.MAC_ADDRESS, mac);
        }

        ApiHelper.init();
    }


}
